package menu

import (
	"parking-lot-go-admin/controller"
	"parking-lot-go-admin/model"
	"parking-lot-go-admin/model/admin"

	"github.com/gin-gonic/gin"
)

func MenuAll(c *gin.Context) {

	//查询信息
	var adminAuthRuleStruct admin.AdminAuthRuleStruct
	var adminAuthRuleData []admin.AdminAuthRuleStruct
	model.GetModelData(
		model.Db,
		adminAuthRuleStruct.TableName(),
		&adminAuthRuleData,
		model.QueryOptions{
			Conditions: map[string]interface{}{},
			OrderBy:    "id desc",
			Debug:      true,
		},
	)

	//数据格式化
	returnData := make([]map[string]interface{}, 0)
	for _, v := range adminAuthRuleData {
		returnData = append(returnData, map[string]interface{}{
			"id":       v.Id,
			"title":    v.Title,
			"menuType": 0,
			"parentId": v.ParentId,
		})
	}

	controller.Success(c, returnData)
}
